<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <title>jQuery打印插件</title>
    <link rel="stylesheet" type="text/css" href="../css/bootstrap.min.css"/>
    <link rel="stylesheet" href="../css/bootstrap-table.css"/>
    <script src="../js/jquery-1.4.4.min.js" ></script>
    <script src="../js/jquery.jqprint-0.3.js" ></script>
</head>
<script language="javascript">
    $(document).ready(function () {
        goodsPrint();
    });
    //干线运输商品明细打印
    function goodsPrint() {
       var requestid =  getUrlParams('requestid');
        $.ajax({
            async: false,
            url: '/interface/camci/print/page/getDkgsxx_Ajax.jsp',
            type: "GET",
            data:{'requestid':requestid},
            dataType: "json",
            success: function (data) {
                $.each(data.datas, function(i, item) {
                    var content = printGoodsTemplate(item.meetName, item.data, item.approverName,
                        item.makeName,item.yfjes,item.dkgss,item.sfjes,);
                    $("#printContet").append(content);

                })
                print("printContet");//调用打印
            }, error: function (e) {
            }
        });
    }

    function printGoodsTemplate(meetName, data, approverName,makeName,yfjes,dkgss,sfjes) {
        var dataContet = "" +
            "<div id='printTable' media='print' style=' margin-top: 22px; padding: 5px;'>" +
            "	<div style='width:100%;margin:0 auto;text-align: center;'>" +
            "    <span style='float:center;margin-right:15px;font-size: 20px;'>"+meetName+"会议专家咨询费代扣个税信息表<span>" +
            "		</div><table  border='1' style='width:100%;' id='printtable2'>" +
            "		    <tr height='30px;'>" +
            "		        <td style='text-align:center;'>序号</td>" +
            "		        <td style='text-align:center;'>姓名</td>" +
            "		        <td style='text-align:center;'>身份证号</td>" +
            "		        <td style='text-align:center;'>应发金额</td>" +
            "		        <td style='text-align:center;'>代扣个税</td>" +
            "		        <td style='text-align:center;'>实发金额</td>" +
            "		    </tr>";
        for (i in data) {
            dataContet +=
                "<tr height='30px;'>" +
                "<td style='text-align:center;'>" + data[i].xh + "</td>" +
                "<td style='text-align:center;'>" + data[i].xm + "</td>" +
                "<td style='text-align:center;'>" + data[i].sfzh + "</td>" +
                "<td style='text-align:center;'>" + data[i].yfje + "</td>" +
                "<td style='text-align:center;'>" + data[i].dkgs + "</td>" +
                "<td style='text-align:center;'>" + data[i].sfje + "</td>" +
                "</tr>";
        }
        dataContet +=
            "	<tr height='30px;'>" +
        "		        <td style='text-align:center;' colspan='3'>合计：</td>" +
        "		        <td style='text-align:center;'>"+yfjes+"</td>" +
        "		        <td style='text-align:center;'>"+dkgss+"</td>" +
        "		        <td style='text-align:center;'>"+sfjes+"</td>" +
        "		</tr> </table>";
        dataContet +=
         " <table style='width: 100%; '>" +
            "<tr>" +
            "<td id='approverName' style='text-align: center;'>审核：  " + approverName + "</td>" +
            "  <td id='makeName' style='text-align: center;'>制单：  " + makeName + "</td>" +
            "</tr> " +
            " </table>" +
            "  <div style='page-break-after:always;'></div> ";

        return dataContet;
    }

    //获取当前时间
    function getTime() {
        var date = new Date();
        var d = date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + date.getHours() + ":" + date.getMinutes() + ":" + date.getSeconds();
        return d;
    }

    function getUrlParams(key) {
        var url = window.location.search.substr(1);
        if (url == '') {
            return false;
        }
        var paramsArr = url.split('&');
        for (var i = 0; i < paramsArr.length; i++) {
            var combina = paramsArr[i].split("=");
            if (combina[0] == key) {
                return combina[1];
            }
        }
        return false;
    }


    //jqPrnt 打印
    function print() {
        $('#printContet').jqprint({
            debug: false,
            globalStyles: true,
            mediaPrint: false,
            stylesheet: null,
            noPrintSelector: ".no-print",
            iframe: false,
            append: null,
            prepend: null,
            manuallyCopyFormValues: true,
            timeout: 10000,
            title: null,
            doctype: '<!doctype html>'
        });
    }
</script>
<style media="print">
    @page {
        size: auto;  /* auto is the initial value */
        margin-top: 0mm; /* this affects the margin in the printer settings */
        margin-bottom: 0mm; /* this affects the margin in the printer settings */
    }
</style>

<body >
<div id="print" class="container ">
    <div id="printContet" media='print' style='width: inherit;height: inherit' class="pdf-wrapper">
    </div>
</div>
</body>
</html>
